﻿@model OpenMVCRM.ViewModels.AddClientAddressViewModel
@{
    ViewBag.Title = "Add Address";
}

<fieldset>
<div class="divContainer">
<div class="divEditBar">
<div class="divBreadCrump">
      <span>You are here : </span>
      @Html.ActionLink("Clients","Index") <span class="breadCrumpSeperator"></span>
       <span> @Html.ActionLink(@Model.ClientName, "Index", new { @id=Model.ClientId}) </span><span class="breadCrumpSeperator"></span>
      Add Address
</div>
<div class="divEditRightLinks"> 
   
</div>
</div>

<div class="divClientInfo">
@Html.HiddenFor(x => x.ClientId)
<h2>@Model.ClientName</h2>



</div>
 <h3>Address Information</h3>

<div class="divCreateFormSub">
   @using (Html.BeginForm())
   {
   <div class="editor-label">
     @Html.LabelFor(m => m.AddressLine1)
   </div>
   <div class="editor-field">
      @Html.TextBoxFor(x => x.AddressLine1)
      @Html.ValidationMessageFor(m => m.AddressLine1)
     
    </div>   
   <div class="editor-label">
     @Html.LabelFor(m => m.AddressLine2)
   </div>
       <div class="editor-field">
    @Html.TextBoxFor(x => x.AddressLine2)
     @Html.ValidationMessageFor(m => m.AddressLine2)
    </div>
    <div class="editor-label">
     @Html.LabelFor(m => m.Countries)
   </div>
       <div class="editor-field">
       @Html.DropDownListFor(x=>x.SelectedCountryID,new SelectList(Model.Countries,"CountryID","CountryName"),"Select")
    </div>
    <div class="editor-label">
     @Html.LabelFor(m => m.SelectedStateID)
   </div>
       <div class="editor-field">
       @Html.DropDownListFor(x => x.SelectedStateID, new SelectList(Model.States, "StateID", "StateName"), "Select")
    </div>
       <div class="editor-label">
     @Html.LabelFor(m => m.City)
   </div>
       <div class="editor-field">
       @Html.TextBoxFor(x => x.City)
        @Html.ValidationMessageFor(m => m.City)
       </div>
          <div class="editor-label">
     @Html.LabelFor(m => m.ZipCode)
   </div>
       <div class="editor-field">
       @Html.TextBoxFor(x => x.ZipCode)
        @Html.ValidationMessageFor(m => m.ZipCode)
       </div>
            <div class="editor-label">
     @Html.LabelFor(m => m.IsPrimary)
   </div>
       <div class="editor-field">
       @Html.CheckBoxFor(x => x.IsPrimary)
       
       </div>
       <p>
       <input type="submit" value="Save" />
       </p>
       @Html.HiddenFor(x => x.ClientId)
   }

 </div>
 </div>

</fieldset>
<script type="text/javascript">
    $(function () {
        $("#SelectedCountryID").change(function () {
            var self = $(this);
            var items="";
            $.getJSON("@Url.Action("Index", "States")?id="+self.val(),function(data){
              $.each(data,function(index,item){
                items+="<option value='"+item.StateID+"'>"+item.StateName+"</option>";
              });
              $("#SelectedStateID").html(items);
            });
        });
    });
</script>